/*************************************init****************************/

function queryResignation_resignation(page){
	sys_loading();
	var parm = $('#queryResignationForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('resignation-query');
	sys_record_parm('resignation',parm);
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#resignationList').html(result);
		}
	});
}


function aidExecuteResignation_resignation(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				queryResignation_resignation();
			}else {
				new $.Zebra_Dialog('操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!', {
				    'buttons':  false,
				    'modal': false,
				    'position': ['right - 20', 'top + 20'],
				    'auto_close': 2000
				});
			}
		}
	});
}


function shield_resignation(code, title) {
	$.Zebra_Dialog('确认要屏蔽标题为： ' + title + ' 的离职信息吗？',{
	'type': 'question','title': '警告','buttons':[
	       {caption:'屏蔽',callback:function() {
	    	   var url = create_url('resignation-shield');
	    	   aidExecuteResignation_resignation(code, url);
			}},
	       {caption:'取消',callback:function(){}
		}]
	});
}

function unshield_resignation(code, title) {
	$.Zebra_Dialog('确认要解除标题为： ' + title + ' 的离职屏蔽状态吗？',{
	'type': 'question','title': '警告','buttons':[
           {caption:'解除',callback:function() {
        	   var url = create_url('resignation-unshield');
        	   aidExecuteResignation_resignation(code, url);
    		}},
           {caption:'取消',callback:function(){}
    	}]
	});
}
function quit_resignation(code, un) {
	$.Zebra_Dialog('确认 ' + un + ' 已离职吗？',{
	'type': 'question','title': '警告','buttons':[
	       {caption:'确认',callback:function() {
	    	   var url = create_url('resignation-quit');
	    	   aidExecuteResignation_resignation(code, url);
			}},
	       {caption:'取消',callback:function(){}
		}]
	});
}
/****************************edit*******************/
function saveResigantion_resignation() {
	var parm = $('#editResigantionForm').serialize();
	var url = create_url('resignation-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_msg('操作成功');
				sys_load_handle('resignation');
			} else if (result == 'null_reason'){ 
				sys_msg('请填写原因');
			} else if (result == 'null_user'){ 
				sys_msg('请选择人员');
			} else if (result == 'null_time'){ 
				sys_msg('请填写离职时间');
			} else if (result == 'null_title'){ 
				sys_msg('请填写标题');
			}else {
				sys_msg('操作失败');
			}
		}
	});
}

